var e = require;
var t = module;
var o = exports;
var n;
function i(e, t) {
    return (i =
        Object.setPrototypeOf ||
        function (e, t) {
            return (e.__proto__ = t), e;
        })(e, t);
}
(o.__esModule = !0), (o.default = void 0);
var a = (function (e) {
    var t, o;
    function n() {
        var t;
        return ((t = e.call(this) || this).gameRecordShareBtn = null), (t.moreGamePortal = null), t;
    }
    (o = e), ((t = n).prototype = Object.create(o.prototype)), (t.prototype.constructor = t), i(t, o);
    var a = n.prototype;
    return (
        (a.init = function () {
            (this.env = window.ks || window.kwaigame || window.wx),
                (this.info = (window.lplatform && lplatform.systemInfo) || this.env.getSystemInfoSync()),
                (this.bh = lplatform.cparam.bannerHeight || 170),
                (this.bw = lplatform.cparam.bannerWidth || Math.min(this.info.windowWidth, (16 * this.bh) / 9)),
                "function" == typeof this.env.getGameRecorder &&
                    (this.gameRecorderManager = this.env.getGameRecorder());
        }),
        (a.initAD = function () {
            this.createRewardedVideo(!1);
        }),
        (a.createGameClub = function () {}),
        (a.showShareMenu = function () {}),
        (a.shareAppMessage = function () {}),
        (a.navigateToMiniProgram = function () {}),
        (a.shareMessageToFriend = function () {}),
        (a.showFavoriteGuide = function () {
            console.log("快手未实现showFavoriteGuide");
        }),
        (a.sendMsgToOpenDataProject = function () {}),
        (a.canRecord = function () {
            return !!this.gameRecorderManager || (console.log("不支持录制游戏画面"), !1);
        }),
        (a.startRecord = function (e) {
            lplatform.plog("startRecord"),
                (this.recordStartCb = e),
                (this.videoPath = null),
                this.gameRecorderManager.start({duration: 30}),
                this.gameRecorderManager.on("start", this.onGameRecordStart.bind(this)),
                this.gameRecorderManager.on("error", this.onGameRecordError.bind(this)),
                this.gameRecorderManager.on("stop", this.onGameRecordStop.bind(this));
            var t = this;
            this.env.onShow(function () {
                lplatform.plog("startRecord this.env.onShow"), t.resumeRecord();
            }),
                this.env.onHide(function () {
                    lplatform.plog("startRecord this.env.onHide"), t.pauseRecord();
                });
        }),
        (a.onGameRecordStart = function () {
            (this.gameRecordStartTime = Date.now()),
                this.recordStartCb && (this.recordStartCb(), (this.recordStartCb = null));
        }),
        (a.onGameRecordError = function (e) {
            lplatform.plog("onGameRecordError:" + JSON.stringify(e), "error");
        }),
        (a.onGameRecordStop = function () {
            lplatform.plog("onGameRecordStop this.recordStopCb:" + this.recordStopCb),
                (this.gameRecordStopTime = Date.now()),
                this.gameRecordStopTime - this.gameRecordStartTime > 4500
                    ? (this.videoPath = "res.videoPath")
                    : lplatform.plog("onGameRecordStop 实际录屏时间少于5秒就有可能分享失败"),
                this.recordStopCb && (this.recordStopCb(this.videoPath), (this.recordStopCb = null));
        }),
        (a.pauseRecord = function () {
            this.gameRecorderManager.pause();
        }),
        (a.resumeRecord = function () {
            this.gameRecorderManager.resume();
        }),
        (a.stopRecord = function (e) {
            this.canRecord() &&
                (lplatform.plog("stopRecord cb:" + e), (this.recordStopCb = e), this.gameRecorderManager.stop());
        }),
        (a.shareRecord = function (e, t) {
            this.gameRecorderManager.publishVideo({
                callback: function callback(o) {
                    null != o && null != o
                        ? (console.log("分享录屏失败: " + JSON.stringify(o)), t && t())
                        : (console.log("分享录屏成功"), e && e());
                }
            });
        }),
        (a.resetRecord = function () {
            this.stopRecord(), (this.videoPath = null);
        }),
        (a.shareInnerRecord = function () {}),
        (a.makeShareUI = function (e, t, o, n, i) {
            void 0 === n && (n = 0),
                void 0 === i && (i = !1),
                this.canRecord()
                    ? lplatform.uiEngine.CreateShareK(
                          function () {
                              this.shareRecord(e, t);
                          }.bind(this),
                          function () {
                              t && t();
                          }.bind(this),
                          o,
                          n,
                          i
                      )
                    : t && t();
        }),
        (a.loadBanner = function () {}),
        (a.onBannerLoad = function () {}),
        (a.onBannerError = function () {}),
        (a.onBannerResize = function () {}),
        (a.showBanner = function () {}),
        (a.hideBanner = function (e) {
            void 0 === e && (e = !1);
        }),
        (a.loadInterstitial = function (e) {
            this.hideInterstitial(),
                console.log("KS loadInterstitial:" + lplatform.cparam.interstitialID),
                (this.insterstitialAd = this.env.createInterstitialAd({adUnitId: lplatform.cparam.interstitialID})),
                this.insterstitialAd.onError(this.onInterstitialError.bind(this)),
                this.insterstitialAd.onClose(this.onInterstitialClose.bind(this)),
                e &&
                    this.insterstitialAd &&
                    (console.log("KS insterstitialAd show"),
                    this.insterstitialAd.show().catch(function (e) {
                        console.log("KS insterstitialAd show error:" + JSON.stringify(e));
                    }));
        }),
        (a.onInterstitialLoad = function () {}),
        (a.onInterstitialError = function (e, t) {
            lplatform.plog("onInterstitialError code:" + JSON.stringify(e) + " msg:" + t);
        }),
        (a.onInterstitialClose = function () {
            this.loadInterstitial(!1);
        }),
        (a.showInterstitial = function () {
            this.loadInterstitial(!0);
        }),
        (a.hideInterstitial = function () {
            this.insterstitialAd &&
                (this.insterstitialAd.offError(this.onInterstitialError),
                this.insterstitialAd.offClose(this.onInterstitialClose),
                this.insterstitialAd.destroy(),
                (this.insterstitialAd = null));
        }),
        (a.createMoreGameBanner = function () {}),
        (a.createMoreGamePortal = function (e, t) {
            void 0 === e && (e = !1), void 0 === t && (t = !1);
        }),
        (a.goToGameOrGameList = function () {
            this.createMoreGamePortal();
        }),
        (a.analytics = function () {}),
        (a.httpRequest = function (e, t, o, n, i, a, r) {
            this.env.request({
                url: e,
                data: i,
                header: a,
                timeout: o,
                method: n,
                dataType: r,
                success: function success(e) {
                    t(null, e.data, e.data);
                },
                fail: function fail(e) {
                    t(e, null, null);
                }
            });
        }),
        n
    );
})(((n = e("PTT")) && n.__esModule ? n : {default: n}).default);
(o.default = a), (t.exports = o.default);
